package com.tian.controller;

import com.tian.pojo.Patient;
import com.tian.service.PatientService;
import com.tian.vo.PageResult;
import com.tian.vo.SysResult;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;



@RestController
@CrossOrigin
@RequestMapping("/patient")
public class PatientController {
    @Autowired
    private PatientService patientService;

    @GetMapping("/list")
    public SysResult getUserList(PageResult pageResult){
        pageResult = patientService.getUserList(pageResult);
        return SysResult.success(pageResult);
    }

    @PostMapping("/addPatient")
    public SysResult addPatient(@RequestBody Patient patient){
        patientService.addPatient(patient);
        return SysResult.success();
    }

    @PutMapping("/updataPatient")
    public SysResult updataPatient(@RequestBody Patient patient){
        patientService.updataPatient(patient);
        return SysResult.success();
    }

    @DeleteMapping("/deletePatient/{id}")
    public SysResult deletePatient(@PathVariable Integer id){
        patientService.deletePatient(id);
        return SysResult.success();
    }
}
